Public Class frmGLProfitLossStatement
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents cbBudget As System.Windows.Forms.CheckBox
    Friend WithEvents dgPrLo As System.Windows.Forms.DataGrid
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents GroupPanel1 As DevComponents.DotNetBar.Controls.GroupPanel
    Friend WithEvents cmdExit As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdPrint As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdRefresh As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmbYear As DevComponents.DotNetBar.Controls.ComboBoxEx
    Friend WithEvents cmbDpt As DevComponents.DotNetBar.Controls.ComboBoxEx
    Friend WithEvents cmbMonth As DevComponents.DotNetBar.Controls.ComboBoxEx
    Friend WithEvents gLlistOfProfitLoss1 As GLlistOfProfitLoss
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.cbBudget = New System.Windows.Forms.CheckBox()
        Me.dgPrLo = New System.Windows.Forms.DataGrid()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.gLlistOfProfitLoss1 = New GLlistOfProfitLoss()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.GroupPanel1 = New DevComponents.DotNetBar.Controls.GroupPanel()
        Me.cmbYear = New DevComponents.DotNetBar.Controls.ComboBoxEx()
        Me.cmdExit = New DevComponents.DotNetBar.ButtonX()
        Me.cmdPrint = New DevComponents.DotNetBar.ButtonX()
        Me.cmdRefresh = New DevComponents.DotNetBar.ButtonX()
        Me.cmbMonth = New DevComponents.DotNetBar.Controls.ComboBoxEx()
        Me.cmbDpt = New DevComponents.DotNetBar.Controls.ComboBoxEx()
        CType(Me.dgPrLo, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupPanel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'cbBudget
        '
        Me.cbBudget.AutoSize = True
        Me.cbBudget.BackColor = System.Drawing.Color.Transparent
        Me.cbBudget.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.cbBudget.Location = New System.Drawing.Point(460, 1)
        Me.cbBudget.Name = "cbBudget"
        Me.cbBudget.Size = New System.Drawing.Size(183, 22)
        Me.cbBudget.TabIndex = 56
        Me.cbBudget.Text = "Show Budgets && Variance"
        Me.cbBudget.UseVisualStyleBackColor = False
        Me.cbBudget.Visible = False
        '
        'dgPrLo
        '
        Me.dgPrLo.AllowSorting = False
        Me.dgPrLo.BackgroundColor = System.Drawing.Color.AliceBlue
        Me.dgPrLo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgPrLo.CaptionVisible = False
        Me.dgPrLo.DataMember = ""
        Me.dgPrLo.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgPrLo.Location = New System.Drawing.Point(20, 101)
        Me.dgPrLo.Name = "dgPrLo"
        Me.dgPrLo.PreferredColumnWidth = 175
        Me.dgPrLo.ReadOnly = True
        Me.dgPrLo.Size = New System.Drawing.Size(610, 340)
        Me.dgPrLo.TabIndex = 280
        Me.dgPrLo.TabStop = False
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.Label1.Location = New System.Drawing.Point(17, 20)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(71, 18)
        Me.Label1.TabIndex = 282
        Me.Label1.Text = "Fiscal Year"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.BackColor = System.Drawing.Color.Transparent
        Me.Label2.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.Label2.Location = New System.Drawing.Point(137, 20)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(94, 18)
        Me.Label2.TabIndex = 283
        Me.Label2.Text = "Report Month"
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.BackColor = System.Drawing.Color.Transparent
        Me.Label3.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.Label3.Location = New System.Drawing.Point(299, 19)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(122, 18)
        Me.Label3.TabIndex = 283
        Me.Label3.Text = "Company/Division"
        '
        'GroupPanel1
        '
        Me.GroupPanel1.CanvasColor = System.Drawing.SystemColors.Control
        Me.GroupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007
        Me.GroupPanel1.Controls.Add(Me.cmbDpt)
        Me.GroupPanel1.Controls.Add(Me.cmbMonth)
        Me.GroupPanel1.Controls.Add(Me.cmbYear)
        Me.GroupPanel1.Controls.Add(Me.cmdExit)
        Me.GroupPanel1.Controls.Add(Me.cmdPrint)
        Me.GroupPanel1.Controls.Add(Me.cmdRefresh)
        Me.GroupPanel1.Controls.Add(Me.Label3)
        Me.GroupPanel1.Controls.Add(Me.Label2)
        Me.GroupPanel1.Controls.Add(Me.cbBudget)
        Me.GroupPanel1.Controls.Add(Me.Label1)
        Me.GroupPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupPanel1.Location = New System.Drawing.Point(0, 0)
        Me.GroupPanel1.Name = "GroupPanel1"
        Me.GroupPanel1.Size = New System.Drawing.Size(651, 500)
        '
        '
        '
        Me.GroupPanel1.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2
        Me.GroupPanel1.Style.BackColorGradientAngle = 90
        Me.GroupPanel1.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground
        Me.GroupPanel1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderBottomWidth = 1
        Me.GroupPanel1.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        Me.GroupPanel1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderLeftWidth = 1
        Me.GroupPanel1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderRightWidth = 1
        Me.GroupPanel1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderTopWidth = 1
        Me.GroupPanel1.Style.CornerDiameter = 4
        Me.GroupPanel1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded
        Me.GroupPanel1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center
        Me.GroupPanel1.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText
        Me.GroupPanel1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near
        Me.GroupPanel1.TabIndex = 284
        Me.GroupPanel1.Text = "GL-P&&L - Statement"
        '
        'cmbYear
        '
        Me.cmbYear.DisplayMember = "Text"
        Me.cmbYear.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.cmbYear.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbYear.ItemHeight = 19
        Me.cmbYear.Location = New System.Drawing.Point(17, 41)
        Me.cmbYear.Name = "cmbYear"
        Me.cmbYear.Size = New System.Drawing.Size(109, 25)
        Me.cmbYear.TabIndex = 284
        '
        'cmdExit
        '
        Me.cmdExit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdExit.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdExit.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdExit.Location = New System.Drawing.Point(545, 437)
        Me.cmdExit.Name = "cmdExit"
        Me.cmdExit.Size = New System.Drawing.Size(82, 27)
        Me.cmdExit.TabIndex = 237
        Me.cmdExit.Text = "Exit"
        '
        'cmdPrint
        '
        Me.cmdPrint.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdPrint.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdPrint.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdPrint.Location = New System.Drawing.Point(367, 438)
        Me.cmdPrint.Name = "cmdPrint"
        Me.cmdPrint.Size = New System.Drawing.Size(82, 26)
        Me.cmdPrint.TabIndex = 236
        Me.cmdPrint.Text = "Print"
        '
        'cmdRefresh
        '
        Me.cmdRefresh.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdRefresh.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdRefresh.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdRefresh.Location = New System.Drawing.Point(457, 438)
        Me.cmdRefresh.Name = "cmdRefresh"
        Me.cmdRefresh.Size = New System.Drawing.Size(82, 26)
        Me.cmdRefresh.TabIndex = 235
        Me.cmdRefresh.Text = "Refresh"
        '
        'cmbMonth
        '
        Me.cmbMonth.DisplayMember = "Text"
        Me.cmbMonth.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.cmbMonth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbMonth.ItemHeight = 19
        Me.cmbMonth.Location = New System.Drawing.Point(138, 41)
        Me.cmbMonth.Name = "cmbMonth"
        Me.cmbMonth.Size = New System.Drawing.Size(154, 25)
        Me.cmbMonth.TabIndex = 284
        '
        'cmbDpt
        '
        Me.cmbDpt.DisplayMember = "Text"
        Me.cmbDpt.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.cmbDpt.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbDpt.ItemHeight = 19
        Me.cmbDpt.Location = New System.Drawing.Point(302, 41)
        Me.cmbDpt.Name = "cmbDpt"
        Me.cmbDpt.Size = New System.Drawing.Size(207, 25)
        Me.cmbDpt.TabIndex = 284
        '
        'frmGLProfitLossStatement
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.ClientSize = New System.Drawing.Size(651, 500)
        Me.ControlBox = False
        Me.Controls.Add(Me.dgPrLo)
        Me.Controls.Add(Me.GroupPanel1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ForeColor = System.Drawing.SystemColors.ControlLightLight
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
        Me.Location = New System.Drawing.Point(50, 20)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmGLProfitLossStatement"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        CType(Me.dgPrLo, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupPanel1.ResumeLayout(False)
        Me.GroupPanel1.PerformLayout()
        Me.ResumeLayout(False)

    End Sub

#End Region
    Private Sub Budgets_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim cYr As Integer = Now.Year
        cmbYear.Items.Clear()
        cmbYear.Items.Add((cYr).ToString())
        cmbYear.Items.Add((cYr + 1).ToString())

        'commented jackson on 01 Aug 201 ------------------------------------------------------------------
        'cmbYear.Items.Add((cYr - 2).ToString() + "-" + (cYr - 1).ToString())
        'cmbYear.Items.Add((cYr - 1).ToString() + "-" + (cYr).ToString())
        'cmbYear.Items.Add((cYr).ToString() + "-" + (cYr + 1).ToString())
        ''cmbYear.Items.Add((cYr + 1).ToString() + "-" + (cYr + 2).ToString())
        'If Now.Month <= 5 Then
        '    cmbYear.SelectedItem = (cYr - 1).ToString() + "-" + (cYr).ToString()
        'Else
        '    cmbYear.SelectedItem = (cYr).ToString() + "-" + (cYr + 1).ToString()
        'End If
        'commented jackson on 01 Aug 201 ------------------------------------------------------------------

        cmbMonth.Items.Clear()
        cmbMonth.Items.Add("January")
        cmbMonth.Items.Add("February")
        cmbMonth.Items.Add("March")
        cmbMonth.Items.Add("April")
        cmbMonth.Items.Add("May")
        cmbMonth.Items.Add("June")
        cmbMonth.Items.Add("July")
        cmbMonth.Items.Add("August")
        cmbMonth.Items.Add("September")
        cmbMonth.Items.Add("October")
        cmbMonth.Items.Add("November")
        cmbMonth.Items.Add("December")
        cmbMonth.SelectedItem = Now.ToString("MMMM")

        Dim GLdata As New GLdataLogic
        Dim ds2 As DataSet
        ds2 = GLdata.GetCompanyDepartments(CompanyID)
        cmbDpt.DataSource = ds2.Tables(0)
        cmbDpt.ValueMember = "AccountID"
        cmbDpt.DisplayMember = "AccountName"
        cmbDpt.SelectedValue = 0
        '
        GLdata = Nothing
    End Sub
    Private Sub dgPrLo_Style()
        With dgPrLo
            .TableStyles.Clear()
            .CaptionBackColor = System.Drawing.Color.SlateBlue
            .CaptionForeColor = System.Drawing.Color.LemonChiffon
            .AllowSorting = False
            .AlternatingBackColor = System.Drawing.Color.AliceBlue
            .ParentRowsBackColor = System.Drawing.Color.Lavender
            .ParentRowsForeColor = System.Drawing.Color.SlateBlue
            .HeaderBackColor = System.Drawing.Color.LemonChiffon
            .AllowNavigation = False
            .ParentRowsVisible = False
            .RowHeadersVisible = False
        End With

        Dim grdTableStyle As New DataGridTableStyle
        With grdTableStyle
            .AlternatingBackColor = Color.AliceBlue
            .HeaderFont = New Font("Calibri", 9.0!, FontStyle.Bold)
            .MappingName = "PRLO"
            .PreferredColumnWidth = 160
            .HeaderBackColor = Color.LightSlateGray
            .HeaderForeColor = Color.LightCyan
            .PreferredRowHeight = 15
            .RowHeadersVisible = False
            .RowHeaderWidth = 0
            .AllowSorting = False
        End With

        Dim cs As DataGridColumnStyle
        cs = New DataGridTextBoxColumn
        cs.Width = 90
        cs.MappingName = "AccountNumber"
        cs.HeaderText = "ACCOUNT"
        cs.NullText = ""
        cs.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs)

        Dim cs3 As DataGridColumnStyle
        cs3 = New DataGridTextBoxColumn
        cs3.Width = 50
        cs3.MappingName = "AccountCenter"
        cs3.HeaderText = "DPT"
        cs3.NullText = ""
        grdTableStyle.GridColumnStyles.Add(cs3)

        Dim cs0 As DataGridColumnStyle
        cs0 = New DataGridTextBoxColumn
        cs0.Width = 250
        cs0.MappingName = "AccountName"
        cs0.HeaderText = "DESCRIPTION"
        cs0.NullText = ""
        grdTableStyle.GridColumnStyles.Add(cs0)

        Dim cs1 As DataGridColumnStyle
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 105
        cs1.MappingName = "MtdAmt"
        cs1.HeaderText = "MTD AMT."
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs1)

        Dim cs2 As DataGridColumnStyle
        cs2 = New DataGridTextBoxColumn
        cs2.Width = 105
        cs2.MappingName = "YtdAmt"
        cs2.HeaderText = "YTD AMT."
        cs2.NullText = ""
        cs2.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs2)

        dgPrLo.TableStyles.Add(grdTableStyle)

    End Sub

    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Me.Hide()
    End Sub

    Private Sub cmdRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRefresh.Click
        Me.Cursor = Cursors.WaitCursor

        Dim GLdata As New GLdataLogic
        Dim ds As DataSet
        Dim ShowBudget As Integer = 0
        If cbBudget.Checked = True Then
            ShowBudget = 1
        End If
        Dim WhichDpt As String = "000"
        If cmbDpt.SelectedValue > 1 Then
            WhichDpt = GLdata.GetProfitCenter(cmbDpt.SelectedValue)
        End If
        ds = GLdata.GetProfitLoss(CompanyID, cmbMonth.SelectedItem, cmbYear.SelectedItem.ToString().Substring(5, 4), cmbDpt.SelectedValue, ShowBudget, WhichDpt)
        Dim drow As DataRow
        For Each drow In ds.Tables(0).Rows
            If drow("AccountCenter").ToString.Trim <> "" Then
                drow("AccountCenter") = WhichDpt
            End If
            If drow("MTDAMT") = 0 Then
                drow("MTDAMT") = System.DBNull.Value
            End If
            If drow("YTDAMT") = 0 Then
                drow("YTDAMT") = System.DBNull.Value
            End If
            'If drow("SL") = 2 Or drow("SL") = 3 Or drow("SL") = 7 Or drow("SL") = 12 Or drow("SL") = 13 Or drow("SL") = 14 Then
            '    If Not IsDBNull(drow("MTDAMT")) Then
            '        If Convert.ToDouble(drow("MTDAMT")) > 0 Then
            '            drow("MTDAMT") = 0 - drow("MTDAMT") '(" & drow("MTDAMT") & ")"
            '        End If
            '    End If
            '    If Not IsDBNull(drow("YTDAMT")) Then
            '        If Convert.ToDouble(drow("YTDAMT")) > 0 Then
            '            drow("YTDAMT") = 0 - drow("YTDAMT")  '"(" & drow("YTDAMT") & ")"
            '        End If
            '    End If
            'End If
            'If drow("SL") = 5 Or drow("SL") = 6 Or drow("SL") = 9 Or drow("SL") = 10 Then
            '    If Not IsDBNull(drow("MTDAMT")) Then
            '        If Convert.ToDouble(drow("MTDAMT")) < 0 Then
            '            drow("MTDAMT") = 0 - drow("MTDAMT")  '"(" & drow("MTDAMT") & ")"
            '        End If
            '    End If
            '    If Not IsDBNull(drow("YTDAMT")) Then
            '        If Convert.ToDouble(drow("YTDAMT")) < 0 Then
            '            drow("YTDAMT") = 0 - drow("YTDAMT") '"(" & drow("YTDAMT") & ")"
            '        End If
            '    End If
            'End If
        Next
        dgPrLo.DataSource = ds.Tables(0)
        'Dim rowCount As Integer = dgPrLo.BindingContext(dgPrLo.DataSource, dgPrLo.DataMember).Count
        'Dim row As Integer = dgPrLo.CurrentRowIndex
        'For row = 0 To rowCount - 1
        'If dgPrLo(row, 4) = 0 Or dgPrLo(row, 5) = 0 Then
        '    dgPrLo(row, 4) = System.DBNull.Value
        '    dgPrLo(row, 5) = System.DBNull.Value
        'End If
        '    If dgPrLo(row, 0) = 2 Or dgPrLo(row, 0) = 3 Or dgPrLo(row, 0) = 7 Or dgPrLo(row, 0) = 12 Or dgPrLo(row, 0) = 13 Or dgPrLo(row, 0) = 14 Then
        '        If Not IsDBNull(dgPrLo(row, 4)) Then
        '            If Convert.ToDouble(dgPrLo(row, 4)) > 0 Then
        '                dgPrLo(row, 4) = "(" & dgPrLo(row, 4).ToString() & ")"
        '            Else
        '                dgPrLo(row, 4) = Format(0 - Convert.ToDouble(dgPrLo(row, 4)), "####0.000")
        '            End If
        '        End If
        '        If Not IsDBNull(dgPrLo(row, 5)) Then
        '            If Convert.ToDouble(dgPrLo(row, 5)) > 0 Then
        '                dgPrLo(row, 5) = "(" & dgPrLo(row, 5).ToString() & ")"
        '            Else
        '                dgPrLo(row, 5) = Format(0 - Convert.ToDouble(dgPrLo(row, 5)), "####0.000")
        '            End If
        '        End If
        '    End If
        '    If dgPrLo(row, 0) = 5 Or dgPrLo(row, 0) = 6 Or dgPrLo(row, 0) = 9 Or dgPrLo(row, 0) = 10 Then
        '        If Not IsDBNull(dgPrLo(row, 4)) Then
        '            If Convert.ToDouble(dgPrLo(row, 4)) < 0 Then
        '                dgPrLo(row, 4) = "(" & Format(0 - Convert.ToDouble(dgPrLo(row, 4)), "####0.000") & ")"
        '            End If
        '        End If
        '        If Not IsDBNull(dgPrLo(row, 5)) Then
        '            If Convert.ToDouble(dgPrLo(row, 5)) < 0 Then
        '                dgPrLo(row, 5) = "(" & Format(0 - Convert.ToDouble(dgPrLo(row, 5)), "####0.000") & ")"
        '            End If
        '        End If
        '    End If
        'Next
        dgPrLo.CurrentRowIndex = 0

        dgPrLo_Style()
        Me.Cursor = Cursors.Default
    End Sub
    Private Sub dgPrLo_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgPrLo.MouseUp
        Dim pt As New Point(e.X, e.Y)
        Dim hti As DataGrid.HitTestInfo = dgPrLo.HitTest(pt)
        If hti.Type = DataGrid.HitTestType.Cell Then
            dgPrLo.CurrentCell = New DataGridCell(hti.Row, hti.Column)
            dgPrLo.Select(hti.Row)
        End If
    End Sub

    Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click
        Me.Cursor = Cursors.WaitCursor
        Try
            Dim ds As DataSet = New DataSet("JisRpt")
            Dim table As DataTable = New DataTable("JisRpt")
            table.Columns.Add("Str1")
            table.Columns.Add("Str2")
            table.Columns.Add("Dec1")
            table.Columns.Add("Dec2")

            Dim mrow As Integer
            Dim cm As CurrencyManager = BindingContext(dgPrLo.DataSource, dgPrLo.DataMember)
            Dim dv As DataView = cm.List
            dv.RowStateFilter = DataViewRowState.CurrentRows
            mrow = dv.Count
            Dim n As Integer
            For n = 0 To mrow - 1
                Dim nrow As DataRow = table.NewRow()
                If dgPrLo(n, 1).ToString.Trim <> "" Then
                    nrow("Str1") = dgPrLo(n, 0) + "-" + dgPrLo(n, 1)
                Else
                    nrow("Str1") = dgPrLo(n, 0)
                End If
                nrow("Str2") = dgPrLo(n, 2)
                nrow("Dec1") = dgPrLo(n, 3)
                nrow("Dec2") = dgPrLo(n, 4)
                table.Rows.Add(nrow)
            Next

            ds.Tables.Add(table)
            gLlistOfProfitLoss1.Load()
            gLlistOfProfitLoss1.SetDataSource(ds)

            gLlistOfProfitLoss1.SetParameterValue("CompanyName", "SAFARI HOUSE GENARAL TRADING COMPANY")
            If cmbDpt.SelectedValue > 1 Then
                gLlistOfProfitLoss1.SetParameterValue("ReportName", "PROFIT & LOSS STATEMENT : " & cmbDpt.Text)
            Else
                gLlistOfProfitLoss1.SetParameterValue("ReportName", "PROFIT & LOSS STATEMENT")
            End If

            gLlistOfProfitLoss1.SetParameterValue("un", UserName)
            gLlistOfProfitLoss1.SetParameterValue("ReportCriteria", "FOR THE PERIOD ENDING:" + cmbMonth.Text + " " + cmbYear.Text)

            If PrntPrv Is Nothing Then
                PrntPrv = New PrintPreviewForm
                PrntPrv.CrRptView.ReportSource = gLlistOfProfitLoss1
                PrntPrv.ShowDialog()
            End If

            'gLlistOfProfitLoss1.PrintToPrinter(1, True, 0, 0)
            gLlistOfProfitLoss1.Close()

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        Me.Cursor = Cursors.Default
    End Sub

  
End Class
